using System;
using System.Drawing;
using FireStarterModeller.BO;
using FireStarterModeller.Test.BO;
using FireStarterModeller.UI;
using Habanero.Base.Exceptions;
using Habanero.BO;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using NUnit.Framework;
using Rhino.Mocks;

namespace FireStarterModeller.Test.UI.Mapper
{
    [TestFixture]
// ReSharper disable ClassWithVirtualMembersNeverInherited.Global
    public class TestPropertyTypeMapper
    {
        [TestFixtureSetUp]
        public void SetupFixture()
        {
            UITestUtils.SetupFixture();
        }

        [SetUp]
        public virtual void SetupTest()
        {
            UITestUtils.SetupTest();
        }

        [Test]
        public void Test_Construct_ShouldConstruct()
        {
            //---------------Set up test pack-------------------
            var extendedComboBox = MockRepository.GenerateMock<IExtendedComboBox>();
            extendedComboBox.Stub(box => box.ComboBox).Return(MockRepository.GenerateMock<IComboBox>());
            extendedComboBox.Stub(comboBox => comboBox.Button).Return(MockRepository.GenerateMock<IButton>());
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            PropertyTypeMapper propertyTypeMapper = new PropertyTypeMapper(extendedComboBox
                    , TestUtilsShared.GetRandomString(), TestUtilsShared.GetRandomBoolean()
                    , MockRepository.GenerateMock<IControlFactory>());
            //---------------Test Result -----------------------
            Assert.IsNotNull(propertyTypeMapper, "Should have constructed successfully");
        }
        [Test]
        public void Test_SetDMSolution_ShouldSetValue()
        {
            //---------------Set up test pack-------------------
            PropertyTypeMapper propertyTypeMapper = GetPropertyTypeMapper();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var dmSolution = MockRepository.GenerateMock<IDMSolution>();
            propertyTypeMapper.DMSolution = dmSolution;
            //---------------Test Result -----------------------
            Assert.AreSame(dmSolution, propertyTypeMapper.DMSolution);
        }

        private static PropertyTypeMapper GetPropertyTypeMapper()
        {
            var extendedComboBox = MockRepository.GenerateMock<IExtendedComboBox>();
            extendedComboBox.Stub(box => box.ComboBox).Return(MockRepository.GenerateMock<IComboBox>());
            extendedComboBox.Stub(comboBox => comboBox.Button).Return(MockRepository.GenerateMock<IButton>());
            return new PropertyTypeMapper(extendedComboBox
                                          , TestUtilsShared.GetRandomString(), TestUtilsShared.GetRandomBoolean()
                                          , MockRepository.GenerateMock<IControlFactory>());
        }
    }
}